import 'package:flutter/material.dart';
import "package:jetour_line/utils/extension_int.dart";

class CommonScaffold extends StatefulWidget {
  final Widget title;
  final Widget body;
  final Color? backgroundColor;
  final List<Widget>? actions;
  final bool showBack;

  const CommonScaffold(
      {super.key,
      required this.title,
      required this.body,
      this.backgroundColor = Colors.white,
      this.actions,
      this.showBack = false});
  @override
  State<StatefulWidget> createState() => _CommonScaffoldState();
}

class _CommonScaffoldState extends State<CommonScaffold> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    // return Scaffold(
    //     extendBodyBehindAppBar: true,
    //     appBar: AppBar(
    //       toolbarHeight: 0,
    //       backgroundColor: Colors.transparent,
    //     ),
    //     body: SafeArea(child: Container(color: Colors.red)));

    if (widget.showBack) {
      return Scaffold(
          backgroundColor: widget.backgroundColor,
          resizeToAvoidBottomInset: false,
          appBar: AppBar(
            titleSpacing: 0,
            elevation: 0,
            title: widget.title,
            centerTitle: true,
            backgroundColor: const Color(0xfff1f1f1),
            leadingWidth: 120.rpx,
            leading: IconButton(
              alignment: Alignment.center,
              icon: Icon(Icons.arrow_back_ios, size: 50.rpx, color: const Color(0xff666666)),
              padding: EdgeInsets.zero,
              onPressed: () {
                Navigator.pop(context);
              },
            ),
            // toolbarHeight: 88.rpx,
          ),
          body: widget.body);
    }
    return Scaffold(
        backgroundColor: widget.backgroundColor,
        resizeToAvoidBottomInset: false,
        appBar: AppBar(
          titleSpacing: 0,
          elevation: 0,
          title: widget.title,
          centerTitle: false,
          backgroundColor: const Color(0xfff1f1f1),
          leading: null,
          leadingWidth: 0,
          automaticallyImplyLeading: false,
        ),
        body: widget.body);
  }
}
